package computacaografica;

public class PontoCart {

	public static final int MIN_X = -600;

	public static final int MAX_X = 600;

	public static final int MIN_Y = -500;

	public static final int MAX_Y = 500;

	private int x, y;

	public PontoCart(int x, int y) {
		if (x > PontoCart.MAX_X) {
			x = PontoCart.MAX_X;
		} else if (x < PontoCart.MIN_X) {
			x = MIN_X;
		}
		if (y > PontoCart.MAX_Y) {
			y = PontoCart.MAX_Y;
		} else if (y < PontoCart.MIN_Y) {
			y = MIN_Y;
		}

		this.x = x;
		this.y = y;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public PontoNormal toNormal() {
		double x = (double) this.x;
		double y = (double) this.y;

		double xN = (x - PontoCart.MIN_X) / (PontoCart.MAX_X - PontoCart.MIN_X);

		double yN = 1.0 - ((y - PontoCart.MIN_Y) / (PontoCart.MAX_Y - PontoCart.MIN_Y));

		return new PontoNormal(xN, yN);
	}

	public Ponto toDisp() {
		PontoNormal pN = toNormal();
		return pN.toDisp();
	}

}
